﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Graph
{
    /// <summary>
    /// Represents the node of a graph or tree
    /// </summary>
    /// <typeparam name="T">The type of object contained in the node</typeparam>
    
    public class Node<T>
    {
        #region Properties

        private T data;
        private NodeList<T> neighbors;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a node with no neighbors or data - set its neighbors and data via the accessors
        /// </summary>
        
        public Node()
        {
            this.neighbors = null;
        }

        /// <summary>
        /// Initializes a node with no neighbors - set its neighbors via the Neighbors accessor
        /// </summary>
        /// <param name="data">The data of the node.</param>
        
        public Node(T data)
        {
            this.data = data;
            this.neighbors = null;
        }
        
        /// <summary>
        /// Initializes a node with neighbors and data
        /// </summary>
        /// <param name="data">The data of the node</param>
        /// <param name="neighbors">The neighbors of the node</param>
        
        public Node(T data, NodeList<T> neighbors)
        {
            this.neighbors = neighbors;
        }

        #endregion

        #region Accessors

        /// <summary>
        /// The value of the node
        /// </summary>
        
        public T Value
        {
            get
            {
                return data;
            }
            set
            {
                data = value;
            }
        }

        /// <summary>
        /// The neighbors of the node
        /// </summary>
        
        public NodeList<T> Neighbors
        {
            get
            {
                return neighbors;
            }
            set
            {
                neighbors = value;
            }
        }

        #endregion
    }
}
